<?php
/**
 * Created by PhpStorm.
 * User: weijer
 * Date: 2018/10/26
 * Time: 21:17
 */

namespace common\validate;


class ReviewFeedback extends BaseValidate
{
    //验证规则
    protected $rule = [];

    public function sceneCreate(): ReviewFeedback
    {
        return $this
            ->append('data.review_feedback', 'require')
            ->append('data.review_feedback.title', 'require|regex:/^[\x{4e00}-\x{9fa5}a-zA-Z_\d]{1,10}$/u')
            ->append('data.review_feedback.project_id', 'require')
            ->append('data.review_feedback.episode_codes', 'require')
            ->append('data.review_feedback_cos_media', 'array');
    }

    public function sceneUpdate()
    {
        return $this
            ->append('data.review_feedback.id', 'require')
            ->append('data.review_feedback.title', 'regex:/^[\x{4e00}-\x{9fa5}a-zA-Z_\d]{1,10}$/u')
            ->append('data.review_feedback_cos_media', 'array');
    }

    public function sceneSaveReviewFeedbackCosMedia(): ReviewFeedback
    {
        return $this
            ->append('cos_key', 'require')
            ->append('object', 'require')
            ->append('file_name', 'require')
            ->append('request_url', 'require');
    }

    public function sceneGetReviewFeedbackList(): ReviewFeedback
    {
        return $this
            ->append('param.filter.project_id', 'require');
    }

    public function sceneAddCosMedia()
    {
        return $this
            ->append('data.review_feedback_id', 'require')
            ->append('data.cos_media', 'require|array')
            ->append('data.cos_media.request_url', 'require')
            ->append('data.cos_media.cos_key', 'require');
    }

    public function sceneDeleteCosMedia()
    {
        return $this
            ->append('data.review_feedback_id', 'require')
            ->append('data.cos_media_id', 'require');
    }

    public function sceneShotReviewFeedbackList()
    {
        return $this
            ->append('param.filter.review_feedback_id', 'require');
    }

    public function sceneAssetReviewFeedbackList()
    {
        return $this
            ->append('param.filter.review_feedback_id', 'require');
    }

    public function sceneGetSendRepairList()
    {

        return $this->append('param.filter.note_ids', 'require');
    }

    public function sceneAddRepairFeedbackNote()
    {
        return $this->append('data.note', 'require');
    }

    public function sceneAddRepairFeedbackNoteData()
    {
        return $this->append('data.note', 'require')
            ->append('data.note.type', 'in:text,video,audio')
            ->append('data.note.module_code', 'require|in:asset,shot')
            ->append('data.note.review_feedback_id', 'require')
            ->append('data.note_relation', 'require')
            ->append('data.note_relation.type', 'requireIf:data.note.module_code,asset|in:step_category,step')
            ->append('data.note_relation.entity_id', 'requireIf:data.note.module_code,asset')
            ->append('data.note_relation.initial_episode_code', 'requireIf:data.note.module_code,asset')
            ->append('data.note_relation.step_category_id', 'requireIf:data.note_relation.type,step_category|integer')
            ->append('data.note_relation.task_id', 'requireIf:data.note_relation.type,step|integer')
            ->append('data.note_relation.extra_data', 'array|requireIf:data.note.module_code,shot')
            ->append('data.note_relation.extra_data.step_category_id', 'integer|requireIf:data.note.module_code,shot')
            ->append('data.note_relation.relation_list', 'array|requireIf:data.note.module_code,shot');
    }

    public function sceneAddShotRepairFeedbackNoteItem()
    {
        return $this->append('relation_type', 'require|in:episode,scene,entity')
            ->append('entity_id', 'integer|requireIf:relation_type,entity')
            ->append('episode_code', 'requireIf:relation_type,episode')
            ->append('showings_number', 'requireIf:relation_type,scene');
    }

    public function sceneGetEntityReviewFeedbackStepCategoryList()
    {
        return $this->append('param.filter.module_code', 'require|in:asset,shot,level');
    }

    public function sceneGetAffectedShotList()
    {
        return $this->append('param.filter.review_feedback_id', 'require|integer')
            ->append('param.filter.relation_type', 'require')
            ->append('param.filter.entity_id', 'requireIf:param.filter.relation_type,step_category|integer')
            ->append('param.filter.step_category_id', 'requireIf:param.filter.relation_type,step_category|integer')
            ->append('param.filter.task_id', 'requireIf:param.filter.relation_type,step|integer');
    }

    public function sceneDeleteRepairFeedbackNote()
    {
        return $this->append('param.filter', 'require|array');
    }

    public function sceneDeleteFeedback()
    {
        return $this->append('param.filter', 'require|array');
    }

    public function sceneGetReviewFeedbackMediaList()
    {
        return $this->append('param.filter.id', 'require');
    }

    public function sceneSendNotify()
    {
        return $this->append('data.review_feedback_id', 'require|integer')
            ->append('data.notify_user_id_list', 'require|array')
            ->append('data.confirm_limit_time', 'require|integer')
            ->append('data.notify_content', 'require');
    }

    public function sceneImportRepairFeedbackNote()
    {
        return $this->append('data.review_feedback_id', 'require|integer')
            ->append('data.list', 'require|array')
            ->append('data.module_code', 'require')
            ->append('data.project_id', 'require');
    }


    public function sceneImportShotRepairFeedbackNoteList()
    {
        return $this->append('initial_episode_code', 'require')
            ->append('showings_number', 'require')
            ->append('name', 'require')
            ->append('step_category_name', 'require');
    }

    public function sceneImportAssetRepairFeedbackNoteList()
    {
        return $this->append('name', 'require')
            ->append('step_category_name', 'require')
            ->append('type', 'in:step_category,step');
    }

    // Import
    public function sceneImport()
    {
        return $this->append('data.list', 'require|array')
            ->append('data.module_code', 'require|in:shot,asset')
            ->append('data.project_id', 'require|integer');
    }

    // ImportBaseInfo
    public function sceneImportBaseInfo()
    {
        return $this->append('initial_episode_code', 'require')
            ->append('showings_number', 'require')
            ->append('name', 'require');
    }

    // ImportDemand
    public function sceneImportDemand()
    {
        return $this->append('reason_type', 'require')
            ->append('text', 'require')
            ->append('demand_status', 'in:已拒绝,已确认,待确认');
    }

    public function saveReviewFeedbackPlan()
    {
        return $this->append('data.review_feedback_id', 'require')
            ->append('data.step_category_id', 'require')
            ->append('data.episode_id', 'require')
            ->append('data.plan_delivery_time', 'require');
    }

    public function sceneGetReviewFeedbackEntityIds()
    {
        return $this->append('param.review_feedback_id', 'require|integer')
            ->append('param.module_code', 'require|in:asset,shot')
            ->append('param.initial_episode_code', 'array');
    }

    public function sceneBatchSaveReviewFeedbackEntityPlan()
    {
        return $this->append('data.review_feedback_entity_ids', 'require|array')
            ->append('data.step_category_id', 'require|integer')
            ->append('data.plan_delivery_time', 'require|integer');
    }

}
